from sklearn.impute import SimpleImputer imputer = SimpleImputer(missing_values=np.nan, strategy='mean')